package com.baizhi.action;

import com.baizhi.entity.Title;
import com.baizhi.service.TitleService;
import com.baizhi.service.TitleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class ShowMyArticleAction extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String name = request.getParameter("MyName");

        HttpSession session = request.getSession();
        TitleService ts = new TitleServiceImpl();
        Title title = new Title();
        title.setName(name);


        List<Title> titles = ts.queryMyTitle(title);
        request.setAttribute("titles",titles);
        session.setAttribute("titles",titles);

        TitleService ts1 = new TitleServiceImpl();
        Title title1 = ts1.show(title);
        session.setAttribute("tittle",title1);

        response.sendRedirect(request.getContextPath()+"/myblog.jsp");
    }
}
